package com.spring.example2;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 * author: xiaochi
 * date: 2025/9/30
 */
public class MqMessage<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 消息主题
     */
    private String topic;

    /**
     * 消息标签
     */
    private String tag;

    /**
     * 消息key
     */
    private String messageKey = UUID.randomUUID().toString().replace("-", "");

    /**
     * 业务key
     */
    private String businessKey;

    /**
     * 消息体
     */
    private T body;

    /**
     * 发送时间
     */
    private Date sendTime = new Date();

    /**
     * 延迟级别
     */
    private Integer delayLevel;

    public static <T> MqMessage<T> of(String topic) {
        return new MqMessage<>(topic);
    }

    public static <T> MqMessage<T> of(String topic, T body) {
        MqMessage<T> message = new MqMessage<>(topic);
        message.setBody(body);
        return message;
    }

    public static <T> MqMessage<T> of(String topic, String tag, T body) {
        MqMessage<T> message = new MqMessage<>(topic);
        message.setTag(tag);
        message.setBody(body);
        return message;
    }

    public MqMessage() {
    }

    public MqMessage(String topic) {
        this.topic = topic;
    }

    public String getMessageKey() {
        return messageKey;
    }

    public void setMessageKey(String messageKey) {
        this.messageKey = messageKey;
    }

    public String getBusinessKey() {
        return businessKey;
    }

    public void setBusinessKey(String businessKey) {
        this.businessKey = businessKey;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }

    public Date getSendTime() {
        return sendTime;
    }

    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    public Integer getDelayLevel() {
        return delayLevel;
    }

    public void setDelayLevel(Integer delayLevel) {
        this.delayLevel = delayLevel;
    }
}